<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
  <style>
    .box .table>tbody>tr>td,
    .box .table>thead>th>td {
      text-align: center;
      vertical-align: middle;
    }
  </style>
</head>

<body>
  <div id="app">
    <h1>{{name}}</h1>
    <div class="box">
      <table class="table table-bordered table-striped">
        <thead>
          <tr class='bg-info'>
            <th>
              全选 <input type="checkbox" v-model='all'>
            </th>
            <th>
              商品名称
            </th>
            <th>图片</th>
            <th>描述</th>
            <th>单价</th>
            <th>数量</th>
            <th>小计</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for='(item,index) in list' :key='index'>
            <td><input type="checkbox" v-model='item.isSelect'></td>
            <td>{{item.title||''}}</td>
            <td><img :src='item.pic' /></td>
            <td>{{item.desc||''}}</td>
            <td>{{item.price|money}}</td>
            <td><input type="number" min=0 v-model='item.count'></td>
            <td>{{item.count*item.price|money}}</td>
            <td><button type="button" class="btn btn-danger" @click='del(item)'>删除</button></td>
          </tr>

          <tr>
            <td colspan="6">
              <h2>总价</h2>
            </td>
            <td colspan="2">{{total|money}}</td>
          </tr>

          <tr>
            <td colspan="8">
              <button type="button" class="btn btn-danger" @click='clear'>清空购物车</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</body>

</html>
<script src="../node_modules/vue/dist/vue.js"></script>
<script src="./jd.js"></script>